import request from '@/utils/request'
import { initData } from '@/api/data'

// 获取构建镜像的表单
export function queryImageBuildingParamForm(data) {
  return request({
    url: '/api/dpImageBuildTpl/getByProjectIdAndEnv?projectId=' + data.projectId + '&env=' + data.env,
    method: 'get'
  })
}

// 获得某个服务某个环境下的配置
export function getServerConfigByProjectIdAndEnv(data) {
  return request({
    url: '/api/dpServerConfig/getByProjectIdAndEnv?projectId=' + data.projectId + '&env=' + data.env,
    method: 'get'
  })
}

// 进行镜像构建
export function imageBuild(data) {
  return request({
    url: 'api/deployRec/buildImage',
    method: 'post',
    data
  })
}

// 进行部署
export function deploy(data) {
  return request({
    url: 'api/deployRec/deploy',
    method: 'post',
    data
  })
}

// 获取项目关联的部署模板参数
export function queryDeployTemplate(data) {
  return request({
    url: 'api/server/queryDeployTemplate',
    method: 'post',
    data
  })
}

// 进行容器部署
export function deployment(data) {
  return request({
    url: 'api/server/deployment',
    method: 'post',
    data
  })
}

// 健康检查
export function healthCheck(data) {
  return request({
    url: 'api/server/healthCheck',
    method: 'post',
    data
  })
}

// 创建部署
export function createProjectDeploy(data) {
  return request({
    url: 'api/deployRec/createProjectDeploy',
    method: 'post',
    data
  })
}

// 查询部署
export function queryDeploy(data) {
  return request({
    url: 'api/deployRec/queryDeploy',
    method: 'post',
    data
  })
}

// 查询部署记录
export function queryDeployRec(data) {
  return initData('api/deployRec', data)
}

// 部署历史
export function deployByHistory(data) {
  return request({
    url: 'api/deployRec/deployByHistory',
    method: 'post',
    data
  })
}

// 查询日志
export function queryLog(data) {
  return request({
    url: 'api/deployRec/queryLog',
    method: 'post',
    data
  })
}

